home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / MISC / BM192A.ZIP / MACROS.S < prev    next >
Encoding:
Text File  |  1996-02-17  |  4.4 KB  |  284 lines

  1. *=======================================================*
  2. *    Macros: [update 11/02/96]            *
  3. *=======================================================*
  4.  
  5. alignment        =    2
  6.  
  7. *-------------------------------------------------------*
  8. *    Stack management                *
  9. *-------------------------------------------------------*
  10.  
  11. push    macro
  12.     move.\0        \1,-(sp)
  13.     endm
  14.  
  15. pop    macro
  16.     move.\0        (sp)+,\1
  17.     endm
  18.  
  19. pushall    macro
  20.     movem.l        d0-a6,-(sp)
  21.     endm
  22.  
  23. popall    macro
  24.     movem.l        (sp)+,d0-a6
  25.     endm
  26.  
  27. align    macro
  28. .o\@    =        *
  29.     ds.b        (alignment-((.o\@)&(alignment-1)))&(alignment-1)
  30.     endm
  31.  
  32.  
  33. ;000
  34. ;113
  35. ;222
  36. ;331
  37. ;400
  38. ;513
  39. ;622
  40. ;731
  41.  
  42. txtlong    macro
  43.     text
  44.     align        text_start
  45.     endm
  46.  
  47. bsslong    macro
  48.     bss
  49.     align        bss_start
  50.     endm
  51.  
  52. datlong    macro
  53.     data
  54.     align        data_start
  55.     endm
  56.  
  57. fixcase    macro
  58.     cmp.b        #'A',\1
  59.     blo.s        .no\@
  60.     cmp.b        #'Z',\1
  61.     bhi.s        .no\@
  62.     and.w        #$FF,\1
  63.     add.w        #'a'-'A',\1
  64. .no\@:    
  65.     endm    
  66.  
  67. *-------------------------------------------------------*
  68. *    DSP communications                *
  69. *-------------------------------------------------------*
  70.  
  71. dspexec    macro
  72.     moveq        #1,d1
  73.     move.l        #(\1_e-\1)/3,d0
  74.     lea        \1,a0
  75.     jsr        DspExecProg
  76.     endm
  77.  
  78. dspwaitwrite        macro
  79.     ifeq        NARG
  80. .ww\@:    btst        #1,$FFFFA202.w
  81.     beq.s        .ww\@
  82.     elseif    
  83. .ww\@:    btst        #1,\1
  84.     beq.s        .ww\@
  85.     endc
  86.     endm
  87.  
  88. dspwaitread        macro
  89.     ifeq        NARG
  90. .wr\@:    btst        #0,$FFFFA202.w
  91.     beq.s        .wr\@
  92.     elseif    
  93. .ww\@:    btst        #0,\1
  94.     beq.s        .ww\@
  95.     endc
  96.     endm
  97.  
  98. dspwrite        macro
  99.     ifeq        '\0'-'r'
  100.     move.l        \1,d0
  101.     dspwaitwrite    \2
  102.     move.w        d0,$FFFFA206.w
  103.     swap        d0
  104.     dspwaitwrite    \2
  105.     move.w        d0,$FFFFA206.w
  106.     elseif
  107.     dspwaitwrite
  108.     ifeq        '\0'-'w'
  109.     move.w        \1,$FFFFA206.w
  110.     elseif
  111.     ifeq        '\0'-'l'
  112.     move.l        \1,$FFFFA204.w
  113.     elseif
  114.     ifeq        '\0'-'b'
  115.     move.b        \1,$FFFFA207.w
  116.     endc
  117.     endc
  118.     endc
  119.     endc
  120.     endm
  121.  
  122. dspread            macro
  123.     ifeq        '\0'-'r'
  124.     elseif
  125.     dspwaitread
  126.     ifeq        '\0'-'w'
  127.     move.w        $FFFFA206.w,\1
  128.     elseif
  129.     ifeq        '\0'-'l'
  130.     move.l        $FFFFA204.w,\1
  131.     elseif
  132.     ifeq        '\0'-'b'
  133.     move.b        $FFFFA207.w,\1
  134.     endc
  135.     endc
  136.     endc
  137.     endc
  138.     endm
  139.  
  140. *-------------------------------------------------------*
  141. *    Display management                 *
  142. *-------------------------------------------------------*
  143.  
  144. vsync    macro
  145. .wv\@:    tst.w        timer
  146.     bne.s        .wv\@
  147.     move.w        #vbilock,timer
  148.     endm
  149.  
  150. triplebuffer        macro
  151.     lea        screen_ptrs,a0
  152.     move.l        (a0),d0
  153.     move.l        4(a0),(a0)
  154.     move.l        8(a0),4(a0)
  155.     move.l        d0,8(a0)
  156.     lsr.w        #8,d0
  157.     move.l        d0,$ffff8200.w
  158.     move.b        #0,$ffff820d.w
  159.     endm
  160.  
  161. *-------------------------------------------------------*
  162. *    Memory management                *
  163. *-------------------------------------------------------*
  164.  
  165. Malloc    macro
  166.     move.l        \1,d0
  167.     addq.l        #4-1,d0
  168.     and.l        #-4,d0
  169.     move.l        d0,-(sp)
  170.     move.w        #$48,-(sp)
  171.     trap        #1
  172.     addq.l        #6,sp
  173.     tst.l        d0
  174.     beq.s        .err\@
  175.     addq.l        #4-1,d0
  176.     and.l        #-4,d0
  177. .err\@:
  178.     endm
  179.  
  180. Mxalloc    macro
  181.     move.l        \1,d0
  182.     addq.l        #4-1,d0
  183.     and.l        #-4,d0
  184.     move.w        #\2,-(sp)
  185.     move.l        d0,-(sp)
  186.     move.w        #68,-(sp)
  187.     trap        #1
  188.     addq.l        #8,sp
  189.     tst.l        d0
  190.     beq.s        .err\@
  191.     addq.l        #4-1,d0
  192.     and.l        #-4,d0
  193. .err\@:
  194.     endm
  195.  
  196. *-------------------------------------------------------*
  197. *    Processor format operations            *
  198. *-------------------------------------------------------*
  199.  
  200. imov    macro
  201.     ifeq        '\0'-'l'
  202.     move.l        \1,d0
  203.     ror.w        #8,d0
  204.     swap        d0
  205.     ror.w        #8,d0
  206.     move.l        d0,\2
  207.     elseif
  208.     ifeq        '\0'-'w'
  209.     move.w        \1,d0
  210.     ror.w        #8,d0
  211.     move.w        d0,\2
  212.     elseif
  213.     move.b        \1,\2
  214.     endc
  215.     endc
  216.     endm
  217.  
  218. *-------------------------------------------------------*
  219. *    I/O macros                    *
  220. *-------------------------------------------------------*
  221.  
  222. Cconout    macro        char
  223.     move.w        \1,-(sp)
  224.     move.w        #2,-(sp)
  225.     trap        #1
  226.     addq.l        #4,sp
  227.     endm
  228.  
  229. Crawcin    macro
  230.     move.w        #7,-(sp)
  231.     trap        #1
  232.     addq.l        #2,sp
  233.     endm
  234.         
  235. Cconws    macro        string
  236.     move.l        \1,-(sp)
  237.     move.w        #9,-(sp)
  238.     trap        #1
  239.     addq.l        #6,sp
  240.     endm
  241.  
  242. Fopen    macro        fname,mode
  243.     move.w        \2,-(sp)
  244.     move.l        \1,-(sp)
  245.     move.w        #61,-(sp)
  246.     trap        #1
  247.     addq.l        #8,sp
  248.     tst.w        d0
  249.     endm
  250.  
  251. Fclose    macro        handle
  252.     move.w        \1,-(sp)
  253.     move.w        #62,-(sp)
  254.     trap        #1
  255.     addq.l        #4,sp
  256.     endm
  257.  
  258. Fread    macro        handle,count,buffer
  259.     move.l        \3,-(sp)
  260.     move.l        \2,-(sp)
  261.     move.w        \1,-(sp)
  262.     move.w        #63,-(sp)
  263.     trap        #1
  264.     lea        12(sp),sp
  265.     endm
  266.  
  267. Fseek    macro        offset,handle,seekmode
  268.     move.w        \3,-(sp)
  269.     move.w        \2,-(sp)
  270.     move.l        \1,-(sp)
  271.     move.w        #66,-(sp)
  272.     trap        #1
  273.     lea        10(sp),sp
  274.     endm
  275.  
  276. Mfree    macro        address
  277.     move.l        \1,-(sp)
  278.     move.w        #73,-(sp)
  279.     trap        #1
  280.     addq.l        #6,sp
  281.     endm
  282.  
  283. *-------------------------------------------------------*
  284.